package com.lizhi.yun.core.role.controller;/**
 * @program: spring-boot
 * @name UppRoleController
 * @description:
 * @author: lizhi
 * @create: 2020-04-13 12:31
 */

import com.lizhi.common.yun.entity.ListResponseResult;
import com.lizhi.common.yun.enums.RoleStateEnum;
import com.lizhi.yun.db.pojo.UppRolePOJO;
import com.lizhi.yun.core.role.handler.UppRoleHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 *@program: spring-boot
 *@name UppRoleController
 *@description:
 *@author: lizhi
 *@create: 2020-04-13 12:31
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/upp/role")
public class UppRoleController {

    @Resource
    private UppRoleHandler uppRoleHandler;

    @PostMapping(path = "/doMain")
    public ListResponseResult doMain(@RequestParam Map<String, Object> map) {
        return uppRoleHandler.doMain(map);
    }

    @PostMapping(value = "/doAdd")
    public ListResponseResult doAdd(@RequestBody UppRolePOJO uppRolePOJO) {
        return uppRoleHandler.insertRecord(uppRolePOJO);
    }

    @PostMapping(value = "/doUpdate")
    public ListResponseResult doUpdate(@RequestBody UppRolePOJO uppRolePOJO) {
        return uppRoleHandler.updateByIdSelective(uppRolePOJO);
    }

    @PostMapping(path = "/isNotexists")
    public ListResponseResult isNotexistsUppRole(String roleId) {
        return uppRoleHandler.isNotexists(roleId);
    }

    @PostMapping(path = "/selectRoleById")
    public ListResponseResult findUppRoleById(String roleId) {
        return uppRoleHandler.selectById(roleId);
    }

    @GetMapping(path = "/selectList")
    public ListResponseResult uppRoleActiveList() {
        return uppRoleHandler.selectList(RoleStateEnum.NORMAL.getEnValue());
    }

    @DeleteMapping(path = "/doDelete")
    public ListResponseResult doDelete(String roleId) {
        return uppRoleHandler.doDelete(roleId);
    }
}
